<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //实例化Promise 对象
        const p = new Promise(function (resolve, reject) {
            setTimeout(() => {
                // let data = '成功读取到后台数据!!!'
                // resolve(data);

                let err = '读取数据失败!!!'
                reject(err);
            }, 1000);
        });

        //调用Promise对象的 then方法  
        //成功调第一个回调，失败调第二个回调
        p.then(function (value) {
            console.log(value);
        }, function (reason) {
            console.error(reason);
        })
    </script>
</body>

</html>